<%@ page import="javax.persistence.EntityManager" %>
<%@ page import="Entity.CreatEntityManager" %>
<%@ page import="javax.persistence.EntityTransaction" %>
<%@ page import="javax.persistence.Query" %>
<%@ page import="java.util.List" %>
<%@ page import="Entity.Courses" %><%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2019/4/9
  Time: 15:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>选课</title>
</head>
<body>
<form action="insert" method="post">
    <h3 align="center">输入学生信息</h3>
    <div align="center">
        学号: <input type="text" name="stu_no" size="20"><br>
        姓名: <input type="text" name="stu_name" size="16"><br>
        专业: <input type="text" name="major" size="16"><br>
    </div>
    <%
        EntityManager em = CreatEntityManager.GetEntityManager();
        EntityTransaction tx = em.getTransaction();
        List<Courses> courses = null;
        try {
            Query query = em.createQuery("SELECT c FROM Courses c");
            courses = query.getResultList();
        } catch (Exception e) {

        } finally {
            em.close();
        }
    %>
    <br>
    <h3 align="center">选择课程</h3>
    <table align="center">
        <tr>
            <td>课程名</td>
            <td>老师</td>
            <td>学时</td>
            <td>选择</td>
        </tr>
        <%
            for (int i = 0; i < courses.size(); i++)
            {
                Courses once=courses.get(i);
        %>
        <tr>
            <td><%=once.getName() %></td>
            <td><%=once.getTeacher() %></td>
            <td><%=once.getScore() %></td>
            <td><input type="checkbox" name="choice" value="<%=once.getNo() %>"></td>
        </tr>
        <%
            }
        %>
    </table>
    <br>
    <div align="center">
        <input type="submit" value="提交">
    </div>
</form>
</body>
</html>
